﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Subgurim.Controles;


namespace Intrack
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {


            
            if(!Page.IsPostBack)
            {

                GMap1.Key = "AIzaSyBitRddrvEvBvzAObtMdPMV6i4rIlZmr4k";
                // GMaps1.Version = "2.43"; 

                double la = -7.76194;
                double lo = -41.88111;
                GLatLng gl = new GLatLng(la, lo);
                //GMap1.setCenter(new GLatLng(37.339085, -121.8914807), 18);
                GMap1.setCenter(gl, 6);

                
                GIcon icon = new GIcon();
                icon.image = "./Imgs/pin-green.png";
                //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                icon.iconSize = new GSize(16, 16);
                //icon.shadowSize = new GSize(22, 20);
                //icon.iconAnchor = new GPoint(la, lo);
                //icon.infoWindowAnchor = new GPoint(la, lo);

                GMarkerOptions mOpts = new GMarkerOptions();
                mOpts.clickable = true;
                mOpts.icon = icon;
                //mOpts.title = "asdsdasd";


                GIcon icon2 = new GIcon();
                icon2.image = "./Imgs/pin-red.png";
                //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                icon2.iconSize = new GSize(16, 16);
                //icon.shadowSize = new GSize(22, 20);
                //icon.iconAnchor = new GPoint(la, lo);
                //icon.infoWindowAnchor = new GPoint(la, lo);

                GMarkerOptions mOpts1 = new GMarkerOptions();
                mOpts1.clickable = true;
                mOpts1.icon = icon2;
                //mOpts.title = "asdsdasd";
                 
                
                MarkerManager mManager = new MarkerManager();
                List<GMarker> mks = new List<GMarker>();
                List<GInfoWindow> iws = new List<GInfoWindow>();
                GMarker mkr;

               //mkr = new GMarker(m1.point + new GLatLng(ir1, ir2));
                BLLCliente cl = new BLLCliente();
                cl.Listar().ForEach(delegate(tbCliente cliente)
                                        {
                                            if (!string.IsNullOrEmpty(cliente.Longi.Trim()))
                                            {
                                                mkr = new GMarker(new GLatLng(double.Parse(cliente.Latit), double.Parse(cliente.Longi)), mOpts);
                                              //mks.Add(mkr);
                                               GInfoWindow window = new GInfoWindow(mkr, cliente.Nome, GListener.Event.mouseover);
                                                iws.Add(window);
                                           }
                                        });


/*
                mkr = new GMarker(new GLatLng(-5.7, -35.2), mOpts);
                mks.Add(mkr);
                mkr = new GMarker(new GLatLng(-5.1, -37.3), mOpts1);
                mks.Add(mkr);
                mkr = new GMarker(new GLatLng(-6.6, -37.4), mOpts);
                mks.Add(mkr);
 * */
                for (int i = 0; i < mks.Count; i++)
                {
                    //mkr = new GMarker(m1.point + new GLatLng(ir1, ir2));
                   // GInfoWindow window = new GInfoWindow(mks[i], "Cidade ", GListener.Event.mouseover);
                  //  iws.Add(window);
                }

                mManager.Add(iws, 6);
                GMap1.markerManager = mManager;
                /*/GMap1.addGMarker(marker);
                GMap1.addInfoWindow
                 */

                //GMap1.mapType = GMapType.GTypes.Hybrid;
                //GMap1.addMapType(GMapType.GTypes.Physical);
                //GMap1.addControl(new GControl(GControl.preBuilt.MapTypeControl));
                // GMap1.enableRotation = true;
            }

            if (!GMap1.IsAjaxPostBack)
            {
                // GMaps Ajax PostBack 
            }
        }

    }
}
